<f:subview xmlns:f="http://java.sun.com/jsf/core"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:nxu="http://nuxeo.org/nxweb/util"
  xmlns:nxdir="http://nuxeo.org/nxdirectory"
  xmlns:nxl="http://nuxeo.org/nxforms/layout"
  xmlns:nxp="http://nuxeo.org/nxweb/pdf"
  xmlns:fn="http://java.sun.com/jsp/jstl/functions"
  id="#{widget.id}">
<c:if test="#{nxl:isLikePlainMode(widget.mode)}">
  <nxu:inputList value="#{field}" model="model">
    <nxdir:directoryEntryOutput
      directoryName="#{widgetProperty_parentDirectory}"
      value="#{fn:split(model.rowData, '/')[0]}"
      localize="#{widgetProperty_localize}" />
    <h:outputText value="/" rendered="#{model.rowData.contains('/')}" />
    <nxdir:directoryEntryOutput
      directoryName="#{widgetProperty_childDirectory}"
      value="#{model.rowData}"
      localize="#{widgetProperty_localize}"
      rendered="#{model.rowData.contains('/')}"
      keySeparator="/" />
    <h:outputText value=", "
      rendered="#{model.rowIndex &lt; (model.rowCount - 1)}" />
  </nxu:inputList>
</c:if>
<c:if test="#{nxl:isLikeViewMode(widget.mode)}">
  <nxu:inputList value="#{field}" model="model">
    <div>
      <nxdir:directoryEntryOutput
        directoryName="#{widgetProperty_parentDirectory}"
        value="#{fn:split(model.rowData, '/')[0]}"
        localize="#{widgetProperty_localize}" />
      <h:outputText value="/" rendered="#{model.rowData.contains('/')}" />
      <nxdir:directoryEntryOutput
        directoryName="#{widgetProperty_childDirectory}"
        value="#{model.rowData}"
        localize="#{widgetProperty_localize}"
        rendered="#{model.rowData.contains('/')}"
        keySeparator="/" />
    </div>
  </nxu:inputList>
</c:if>
<c:if test="#{widget.mode == 'pdf'}">
  <nxp:html>
    <nxdir:chainSelect id="#{widget.id}_viewselect" size="2"
      value="#{field}" displayValueOnly="true" multiSelect="true"
      defaultRootKey="">
      <nxdir:chainSelectListbox index="0" size="4"
      directoryName="#{widgetProperty_parentDirectory}"
      localize="#{widgetProperty_localize}"
      id="#{widget.id}_parent" />
      <nxdir:chainSelectListbox size="4"
        directoryName="#{widgetProperty_childDirectory}" index="1"
        localize="#{widgetProperty_localize}"
        id="#{widget.id}_child" />
      <nxdir:chainSelectStatus display="value" id="#{widget.id}_status" />
    </nxdir:chainSelect>
  </nxp:html>
</c:if>
<c:if test="#{widget.mode == 'edit'}">

  <a4j:region id="#{widget.id}_region" renderRegionOnly="true">
    <nxdir:chainSelect size="2" value="#{field}"
      id="#{widget.id}_editselect"
      multiSelect="true"
      multiParentSelect="true"
      allowRootSelection="#{widgetProperty_allowRootSelection}"
      allowBranchSelection="#{widgetProperty_allowBranchSelection}"
      defaultRootKey=""
      required="#{widgetProperty_required}">
      <nxdir:chainSelectListbox index="0" size="4"
        directoryName="#{widgetProperty_parentDirectory}"
        localize="#{widgetProperty_localize}"
        id="#{widget.id}_parent"
        ordering="#{empty widgetProperty_ordering?'label':widgetProperty_ordering}">
        <a4j:ajax event="change"
          render="#{widget.id}_child #{widget.id}_message"
          execute="@this" />
      </nxdir:chainSelectListbox>
      <f:subview rendered="#{widgetProperty_on2rows}">
        <br />
      </f:subview>
      <nxdir:chainSelectListbox size="4" index="1"
        directoryName="#{widgetProperty_childDirectory}"
        localize="#{widgetProperty_localize}"
        id="#{widget.id}_child"
        ordering="#{empty widgetProperty_ordering?'label':widgetProperty_ordering}" />
      <a4j:commandButton value="#{messages['command.add']}"
        styleClass="button" immediate="true"
        actionListener="#{chainSelectActions.add}"
        render="#{widget.id}_status #{widget.id}_message"
        status="#{widget.id}_ajax_status"
        id="#{widget.id}_add" />
      <br />
      <nxdir:chainSelectStatus display="value"
        entryCssStyle="background-color: #DDEEFF"
        label="#{messages['label.chainSelect.selection']}"
        id="#{widget.id}_status">
        <f:facet name="removeButton">
          <a4j:commandButton
            actionListener="#{chainSelectActions.delete}"
            execute="@this" render="#{widget.id}_status"
            status="#{widget.id}_ajax_status"
            image="/icons/toggle_minus.png"
            id="#{widget.id}_delete" />
        </f:facet>
      </nxdir:chainSelectStatus>
    </nxdir:chainSelect>
  </a4j:region>
  <h:message styleClass="errorMessage" for="#{widget.id}_editselect"
    id="#{widget.id}_message" />

  <a4j:status name="#{widget.id}_ajax_status">
    <f:facet name="start">
      <h:graphicImage value="/img/standart_waiter.gif" />
    </f:facet>
  </a4j:status>

</c:if>
</f:subview>